import fetch from 'common/src/utils/fetch';

function assessRulesSettingList(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/assessRulesSettingList',
        method: 'post',
        data
    });
}

function insertRulesSetting(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/insertRulesSetting',
        method: 'post',
        data
    });
}

function updateRulesSetting(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/updateRulesSetting',
        method: 'post',
        data
    });
}

function deleteRulesSetting(data) {
    return fetch({
        url: '/api/studentservice/assessSetting/deleteRulesSetting',
        method: 'delete',
        data
    });
}

function getWhiteListCourse(params) {
    return fetch({
        url: '/api/cultureservice/bclCourses/page' + getParams(params),
        method: 'get'
    });
}

function getParams(params) {
    var paramsData = [];
    for (const key in params) {
        params[key] &&
            paramsData.push(
                key + '=' + params[key]
            );
    }
    if (paramsData.length)
        return '?' + paramsData.join('&');
    else
        return '';
}

const rulesSetApi = {
    'assessRulesSettingList': assessRulesSettingList,
    'insertRulesSetting': insertRulesSetting,
    'updateRulesSetting': updateRulesSetting,
    'deleteRulesSetting': deleteRulesSetting,
    'getWhiteListCourse': getWhiteListCourse,
}

export default rulesSetApi;